package com.hopedove.yieldmanage.domain.net;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.hopedove.net.domain.JsonParamRequest;
import com.hopedove.yieldmanage.entity.ProductInputEntity;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.List;

public class SaveYieldInput extends JsonParamRequest {

    public SaveYieldInput(String userBean, List<ProductInputEntity> productList, String bmmc) {
        try {
            JSONObject jsonObject = new JSONObject(userBean);
            putParam("userBean", jsonObject);

            Gson gson = new GsonBuilder().serializeNulls().create();
            String result = gson.toJson(productList);
            JSONArray jsonArray = new JSONArray(result);

            putParam("jsonData", jsonArray);
            putParam("BMMC", bmmc);
        } catch (Exception e) {
            // ignore
        }
    }

    @Override
    protected String getMethod() {
        return "wageYieldInputedit";
    }
}
